package com.company.cloud.user.modules.demo.service.impl;

import com.company.cloud.user.modules.demo.models.CacheTestModel;
import com.company.cloud.user.modules.demo.service.JetCacheTestService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class JetCacheTestServiceImpl implements JetCacheTestService {


    private static Map<Integer,CacheTestModel> map = new HashMap<>();

    static {
        System.out.println("+++++++++++++init Map++++++++++++++++++");
        CacheTestModel ctm1=new CacheTestModel(1,"wjj","nt");
        CacheTestModel ctm2=new CacheTestModel(2,"anros","sh");
        CacheTestModel ctm3=new CacheTestModel(3,"wang","nj");
        map.put(ctm1.getId(),ctm1);
        map.put(ctm2.getId(),ctm2);
        map.put(ctm3.getId(),ctm3);
    }



    @Override
    public CacheTestModel get(int id) {
        System.out.println("+++++++++++++++get by id++++++++++++++++++");
        return map.get(id);
    }

    @Override
    public void del(int id) {
        System.out.println("+++++++++++++++del by id++++++++++++++++++");
    }

    @Override
    public CacheTestModel get2(CacheTestModel param) {
        System.out.println("++++++++++++++get 22222+++++++++++++++++");
        return param;
    }
}
